﻿//-----------------------------------------------------------------------
// <copyright file="RetractTarget.cs" company="tuliprules.org">
//     Copyright (c) 2011 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the RetractTarget class.</summary>
//-----------------------------------------------------------------------
namespace Tulip.Rules.Models.Rif.Prd
{
    using System;
    using System.ComponentModel;
    using System.Xml.Serialization;

    /// <summary>
    /// Represents the target of a Retract action.
    /// </summary>
    [Serializable]
    [DesignerCategory(@"code")]
    [XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2007/rif#")]
    [XmlRoot(Namespace = "http://www.w3.org/2007/rif#", IsNullable = false)]
    public class RetractTarget : IRifPrdElement
    {
        /// <summary>
        /// The item field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private object itemField;

        /// <summary>
        /// The first TERM field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private object term1Field;

        /// <summary>
        /// The second TERM field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private object term2Field;

        /// <summary>
        /// The ordered field.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        private string orderedField;
       
        /// <summary>
        /// Initializes a new instance of the <see cref="RetractTarget"/> class. 
        /// </summary>
        public RetractTarget() 
        {
            this.orderedField = "yes";
        }
        
        /// <summary>
        /// Gets or sets an atom formula, positional or with named arguments, a
        /// Frame formula, or a term consisting of a constant, a logical variable
        /// an external term or a list. 
        /// </summary>
        [XmlElement("Atom", typeof(Atom), Order = 0)]
        [XmlElement("Frame", typeof(Frame), Order = 0)]
        [XmlElement("Const", typeof(Const), Order = 0)]
        [XmlElement("Var", typeof(Var), Order = 0)]
        [XmlElement("External", typeof(ExternalTermType), Order = 0)]
        [XmlElement("List", typeof(List), Order = 0)]
        //// [XmlChoiceIdentifier]
        public object Item
        {
            get
            {
                return this.itemField;
            }

            set
            {
                this.itemField = value;
            }
        }

        /// <summary>
        /// Gets or sets a term consisting of a constant, a logical variable
        /// an external term or a list. 
        /// </summary>
        [XmlElement("Const", typeof(Const), Order = 1)]
        [XmlElement("Var", typeof(Var), Order = 1)]
        [XmlElement("External", typeof(ExternalTermType), Order = 1)]
        [XmlElement("List", typeof(List), Order = 1)]
        public object Term1
        {
            get
            {
                return this.term1Field;
            }

            set
            {
                this.term1Field = value;
            }
        }

        /// <summary>
        /// Gets or sets a term consisting of a constant, a logical variable
        /// an external term or a list. 
        /// </summary>
        [XmlElement("Const", typeof(Const), Order = 2)]
        [XmlElement("Var", typeof(Var), Order = 2)]
        [XmlElement("External", typeof(ExternalTermType), Order = 2)]
        [XmlElement("List", typeof(List), Order = 2)]
        public object Term2
        {
            get
            {
                return this.term2Field;
            }

            set
            {
                this.term2Field = value;
            }
        }

        /// <summary>
        /// Gets or sets a flag indicating if the list of roles is ordered.
        /// </summary>
        [XmlAttribute("ordered")]
        public string Ordered 
        {
            get
            {
                return this.orderedField;
            }

            set
            {
                this.orderedField = value;
            }
        }
    }
}